import 'package:flutter/material.dart';
import '../../helper/utils/util.dart';
import 'controller.dart';

class AppTabPage extends GetView<AppTabController> {
  const AppTabPage({Key? key}) : super(key: key);

  // Widget getIcon(String url) {

  //   return Image.asset(
  //     url.imgPathAppTab,
  //     width: 18.r,
  //     height: 18.r,
  //     fit: BoxFit.contain,
  //   );
  // }

  Widget getIcon(IconData icon, {bool isActive = false}) {
    return Icon(
      icon,
      color: isActive ? ColorsUtil.theme : ColorsUtil.separator,
      size: 22.r,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Obx(
      () => Scaffold(
          body: Stack(
            children: [
              IndexedStack(
                index: controller.state.currentIndex.value,
                children: controller.state.pages,
              ),
            ],
          ),
          bottomNavigationBar: BottomNavigationBar(
            type: BottomNavigationBarType.fixed,
            selectedItemColor: ColorsUtil.theme,
            unselectedItemColor: ColorsUtil.subTitle,
            items: controller.state.items
                .map((e) => BottomNavigationBarItem(
                    label: e.title,
                    icon: getIcon(e.icon),
                    activeIcon: getIcon(e.activeIcon, isActive: true)))
                .toList(),
            currentIndex: controller.state.currentIndex.value,
            selectedFontSize: 12,
            unselectedFontSize: 12,
            onTap: (index) => controller.clickTab(index),
            backgroundColor: Colors.white,
          )),
    );
  }
}
// PageView(
//             physics: const NeverScrollableScrollPhysics(),
//             controller: controller.state.pageController,
//             children: controller.state.pages,
//           )